iT邦幫忙

2024 iThome 鐵人賽

DAY 8
0

這篇介紹如何實作DatabaseContract,主要用於對接view與presenter


DatabaseContract

public interface DatabaseContract {
    interface view{
        void addSuccess();
        void addError();
        void getSuccess(String getId,
                        String getRoomNumber,
                        Boolean getPlayer1OnlineState,
                        Boolean getPlayer2OnlineState,
                        String getMoveState,
                        HashMap<String,Object> getChessboardData,
                        HashMap<String,Object> getChessmanMoveData,
                        String getTurn,
                        HashMap<String,Object> getPawnMove1,
                        HashMap<String,Object> getPawnMove2,
                        HashMap<String,Object> getCastlingMove1,
                        HashMap<String,Object> getCastlingMove2,
                        String getDate,
                        String getPlayer1message,
                        String getPlayer2message,
                        String getWinPlayer);
        void getError();
        void uploadSuccess();
        void uploadError();
        void deleteSuccess();
        void deleteError();
    }
    interface presenter{
        void addData(String roomNumber,
                     Boolean player1OnlineState,
                     Boolean player2OnlineState,
                     String moveState,
                     HashMap<String,Object> chessboardData,
                     HashMap<String,Object> chessmanMoveData,
                     String turn,
                     HashMap<String,Object> pawnMove1,
                     HashMap<String,Object> pawnMove2,
                     HashMap<String,Object> castlingMove1,
                     HashMap<String,Object> castlingMove2,
                     String date,
                     String player1message,
                     String player2message,
                     String winPlayer);
        void getData(String roomNumber);
        void uploadData(String id,
                        String key,
                        Object newValue);
        void deleteData(String id);
    }
}

這樣我們就能成功在各個activity中回調firebase的方法了


上一篇
【DAY 07】firebase - DatabasePresenter & DatabaseContract - deleteData
下一篇
【DAY 09】data - DialogData
系列文
基於Firebase整合生成式AI研究開發雙人國際象棋系統(Based on Firebase and AI to research chess system)30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言